<?php require_once '../ptnhuan-web1/data/users.php'; ?>
<form method="POST">
    <table>
        <tr>
            <td>Username: </td>
            <td><input name="username" type="text"</td>
        </tr>
        <tr>
            <td>Password: </td>
            <td><input name="password" type="password">
        </tr>
    </table>
    <input name="submit" type="submit" value="Enter"></p>
</form>

<?php if (isset($_POST['submit'])): ?>
    <?php
    $username = $_POST['username'];
    $password = $_POST['password'];
    $Ok = FALSE;
    $index = -1;
    for ($i = 0; $i < count($users); $i++) {
        if ((strcmp($users[$i]['username'], $username) == 0) &&
                (strcmp($users[$i]['password'], $password) == 0)) {
            $Ok = TRUE;
            $index = $i;
        }
    }
    if ($Ok) {
        header("Location: http://localhost:82/thinh2-web1/file.php?uid=" . $users[$index]['id']);
    } else {
        echo "Dang nhap that bai";
    }
    ?>
<?php endif; ?>
